package com.example.examapp.controller;

import com.example.examapp.model.Answer;
import com.example.examapp.service.AnswerService;
import org.lzx.base.common.Result;
import org.lzx.base.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version v1.0
 * @package com.example.examapp.controller
 * @data 2022/12/4 13:22
 */
@RestController
@RequestMapping("/answer")
public class AnswerController {

    @Autowired
    private AnswerService answerService;

    @PostMapping("/save")
    public Result save(@RequestBody Answer answer){
        return ResultUtil.success(answerService.save(answer));
    }

    @DeleteMapping("/{id}")
    public Result del(@PathVariable("id")String id){
        return ResultUtil.success(answerService.del(id));

    }

    @GetMapping("/list")
    public Result list(){
        return ResultUtil.success(answerService.queryAll());
    }

    @GetMapping("/result")
    public Result result(){
        return answerService.result();
    }


}
